using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using QuanLyKho.DAL;
using QuanLyKho.Entity;
namespace QuanLyKho.BL
{
    class bHangHoa :bBase
    {
        DAO dao = new DAO();
        public int insertHangHoa(eHangHoa hh)
        {
            IList<SqlParameter> paramList = new List<SqlParameter>();
            SqlParameter pr = new SqlParameter("@maHang", SqlDbType.VarChar);
            pr.Value =hh.maHang;
            paramList.Add(pr);

            pr = new SqlParameter("@tenHang", SqlDbType.NVarChar);
            pr.Value = hh.tenHang;
            paramList.Add(pr);

            pr = new SqlParameter("@ngayNhap", SqlDbType.DateTime);
            pr.Value = hh.ngayNhap;
            paramList.Add(pr);

            pr = new SqlParameter("@soLuong", SqlDbType.Int);
            pr.Value = hh.soLuong;
            paramList.Add(pr);

            pr = new SqlParameter("@donGia", SqlDbType.Float);
            pr.Value = hh.donGia;
            paramList.Add(pr);

            pr = new SqlParameter("@donViTinh", SqlDbType.VarChar);
            pr.Value = hh.donViTinh;
            paramList.Add(pr);

            pr = new SqlParameter("@nhId", SqlDbType.Int);
            pr.Value = hh.nhId;
            paramList.Add(pr);

            int r = dao.ExecuteNonQuery("insertHangHoa", CommandType.StoredProcedure, paramList);
            dao.CloseConnection();
            return r;
        }

        public DataTable getAllHangHoa()
        {
            DataTable dt = dao.ExecuteQueryDataTable("getAllHangHoa", CommandType.StoredProcedure, new List<SqlParameter>());
            dao.CloseConnection();
            return dt;
        }
    }
}
